package com.invengo.module_check.ui.fragment.first_check;

import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import com.invengo.module_check.BR;
import com.invengo.module_check.R;
import com.invengo.module_check.databinding.FragmentRecordRefreshingBinding;

import me.goldze.mvvmhabit.base.BaseFragment;

public class RecordRefreshFragment extends BaseFragment<FragmentRecordRefreshingBinding, RecordViewModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_record_refreshing;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }
    @Override
    public void changeModel() {
        viewModel.setFragment(this.getClass().getSimpleName());
    }
    @Override
    public void initData() {
        binding.refreshLayout.autoRefresh();
    }
    @Override
    public void initViewObservable() {
        viewModel.ui.refreshTipEvent.observe(this, s -> binding.tip.setText(Html.fromHtml(s)));
        viewModel.ui.finishLoad.observe(this, s ->{
            binding.refreshLayout.finishRefresh();
            binding.refreshLayout.finishLoadMore();
        });
    }
}
